<?php

/*
 * login/register
 * @author sky
 * create_time 2017-04-30
 */


namespace App\Front\Controllers\Index;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Constraint;
use App\Admin\Controllers\Controller;
use App\Admin\Models\Logs;
use App\Front\Models\register;
use Session;

class LoginController extends Controller {


    /*
     * login/resigister
     * @author sky
     * create_time 2017-04-30
     */
    public function login(Request $request) {

        return view('front.login');
    }
    
    // public function register() {
    //     return view('front.register');
    // }

    public function gologin(Request $request) {
        $name = $request->input('name');
        $password = $request->input('pass');
        $data = Register::gologin($name); 
        $re_name = $data[0]['attributes']['name'];
        $re_password = $data[0]['attributes']['password'];
        $nick = $data[0]['attributes']['nick'];
        if($name == $re_name && $password == $re_password){
            $request->session()->put('name',$name);
            $request->session()->put('nick',$nick);
            $request->session()->put('password',$password);
            return "true";
        }else{
            return "false";
        }
    }
}